<!DOCTYPE html>
<html>
<title>资讯管理</title>
<body class="fixed-left">
<div id="wrapper">
    <#include "../header.html">
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <form class="narbar-form navbar-left" role="search" method="get" style="width: 500px;">
                        <div class="form-group col-xs-6" style="margin-top: 10px;">
                            <input type="text" value="<#if queryParam.title??>${queryParam.title}</#if>"
                                   name="title" placeholder="标题" class="form-control"/>
                        </div>
                        <button type="submit" class="btn btn-default col-xs-3" style="margin-top: 10px">搜索</button>
                        <a href="/admin/news/add" class="btn btn-default col-xs-2" style="margin-top: 10px;margin-left: 10px">添加内容</a>
                    </form>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th width="5%">编号</th>
                                <th width="10%">名称</th>
                                <th width="10%">分类</th>
                                <th width="10%">缩略图</th>
                                <th width="10%">关键词</th>
                                <th width="5%">状态</th>
                                <th width="5%">作者</th>
                                <th width="10%">创建时间</th>
                                <th width="10%">修改时间</th>
                                <th width="5%">浏览次数</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#list pageInfo.list as post>
                                <tr>
                                    <td>
                                        ${post.id}
                                    </td>
                                    <td>${post.title}</td>
                                    <td>
                                        <#list category as cate>
                                            <#if cate.id == post.cateid>
                                                ${cate.name}
                                            </#if>
                                        </#list>
                                    </td>
                                    <td><img src="${post.thumb}" width="50" height="50" /></td>
                                    <td>${post.keywords}</td>
                                    <td>
                                        <#if post.status == 2>正常
                                            <#else>禁用
                                        </#if>
                                    </td>
                                    <td>
                                        <#list users as user>
                                            <#if user.id == post.userid>
                                                ${user.username}
                                            </#if>
                                        </#list>
                                    </td>
                                    <td>${post.createtime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                    <td>${post.updatetime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                    <td>${post.readnum}</td>
                                    </td>
                                    <td>
                                        <a href="/admin/news/edit/${post.id}"
                                           class=" btn btn-primary btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-edit"></i> <span>编辑</span></a>
                                        <a href="javascript:void(0)" onclick="delPost(${post.id});"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-trash-o"></i> <span>删除</span></a>
                                    </td>
                                </tr>
                            </#list>
                            </tbody>
                        </table>
                        <div class="clearfix">
                            <ul class="pagination  m-b-5 pull-right">
                                <#if pageInfo.hasPreviousPage>
                                    <li>
                                        <a href="?page=${pageInfo.prePage}" aria-label="Previous">
                                            <i class="fa fa-angle-left"></i>&nbsp;上一页
                                        </a>
                                    </li>
                                </#if>
                                <#list pageInfo.navigatepageNums as nav>
                                    <#if nav == pageInfo.pageNum>
                                        <li class="active"><a href="#">${nav}</a></li>
                                    </#if>
                                    <#if nav != pageInfo.pageNum>
                                        <li class="">
                                            <a href="?page=${nav}&rows=${pageInfo.pageSize}&title=<#if queryParam.title??>${queryParam.title}</#if>">${nav}</a>
                                        </li>
                                    </#if>
                                </#list>

                                <#if pageInfo.hasNextPage>
                                    <li>
                                        <a thref="?page=${pageInfo.nextPage}" aria-label="Next">
                                            下一页&nbsp;<i class="fa fa-angle-right"></i>
                                        </a>
                                    </li>
                                </#if>

                                <li><span>共${pageInfo.pages}页</span></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!--<div th:replace="admin/footer :: footer-content"></div>-->
            </div>
        </div>
    </div>
</div>
<#include "../footer.html">
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();
    function delPost(id) {
        tale.alertConfirm({
            title:'确定删除该文章吗?',
            then: function () {
                tale.post({
                    url : '/admin/news/delete',
                    data: {id: id},
                    success: function (result) {
                        if(result){
                            tale.alertOkAndReload('删除成功');
                        } else {
                            tale.alertError('删除失败');
                        }
                    }
                });
            }
        });
    }
    /*]]>*/
</script>
</body>
</html>